package com.itheima.bean;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.annotation.Resource;

@Component("cat")
public class Cat {
    @Autowired
    private Dog dog;
    @Resource
    private Mouse mouse;
    int age;
    public Dog getDog() {
        return dog;
    }

    public void setDog(Dog dog) {
        System.out.println("<<<<<< this.dog = dog;");
        this.dog = dog;
    }

    public Mouse getMouse() {
        return mouse;
    }

    public void setMouse(Mouse mouse) {
        System.out.println("<<<<<< this.mouse = mouse;");
        this.mouse = mouse;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public Cat() {
        System.out.println("new Cat()");
    }
    public Cat(int age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return "Cat{" +
                "age=" + age +
                '}';
    }

    @PostConstruct
    public void init(){
        System.out.println("cat @PostConstruct init");
    }
    @PreDestroy
    public void destroy(){
        System.out.println("cat @PostConstruct destroy");
    }
}
